package com.um.jdy.platform.station.controller;

import com.um.jdy.platform.station.entity.dto.SharingDTO;
import com.um.jdy.platform.station.entity.dto.UserSharingDTO;
import com.um.jdy.platform.station.entity.dto.StationSharingPageDTO;
import com.um.jdy.platform.station.entity.vo.StationSharingItemVO;
import com.um.jdy.platform.station.entity.vo.StationSharingUserItemVO;
import com.um.jdy.platform.station.entity.vo.UserSharingItemVO;
import com.um.jdy.platform.station.manager.StationSharingManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 管理类：站场
 *
 * @author cs
 * 日期 2023/5/24
 * 版权所有 广州优匠科技有限公司
 */
@Api(tags = "网点管理")
@Validated
@RestController
@RequestMapping("/api/v1/cms/station/sharing")
@ApiPermission("sharing")
@TokenRequired
public class StationSharingController extends BaseController<StationSharingManager> {

    /**
     * 查询分成网点
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation("查询分成站场")
    @PostMapping("/page")
    public Response<Page<StationSharingItemVO>> getPage(@RequestBody StationSharingPageDTO params){
        return manager.getPage(params);
    }

    /**
     * 查询分成用户
     * @param params
     * @return
     */
    @ApiPermission("user_page")
    @ApiOperation("查询分成用户")
    @PostMapping("/user_page")
    public Response<Page<StationSharingUserItemVO>> getUserPage(@RequestBody StationSharingPageDTO params){
        return manager.getUserPage(params);
    }

    @ApiPermission("save")
    @ApiOperation("保存或更新")
    @PostMapping
    public Response saveEntity( @RequestBody SharingDTO dto) {
        return manager.saveEntity(dto);
    }

    /**
     * 分成人员列表
     *
     * @param dto
     * @return
     */
    @ApiPermission("list")
    @ApiOperation("分成人员列表")
    @PostMapping("/get")
    public Response<List<UserSharingItemVO>> getSharingListByParentId(@RequestBody UserSharingDTO dto) {
        return manager.getSharingListByParentId(dto);
    }

    @ApiPermission("delete")
    @ApiOperation("删除")
    @DeleteMapping({"{id}"})
    public Response<Object> delete(@PathVariable String id) {
        return manager.delete(id);
    }

    @ApiPermission("delete_all")
    @ApiOperation("批量删除")
    @DeleteMapping
    public Response<Object> deleteIds(@ApiParam(value = "删除的id",required = true) @RequestBody List<String> ids) {
        return manager.deleteIds(ids);
    }

}
